//
// Created by hay boy on 2022/6/26.
//
#include <ctime>
#include "stackTest.h"

int testStack() {
    stack<int> s;
    long c = clock();
    for (int i = 0; i < 5000000; i++) {
        s.push(rand());
    }
    for (int i = 0; i < 5000000; i++) {
        s.top();
        s.pop();
    }
    return clock()-c;
}

int testArrayStack() {
    ArrayStack<int> s;
    long c = clock();
    for (int i = 0; i < 5000000; i++) {
        s.push(rand());
    }
    for (int i = 0; i < 5000000; i++) {
        s.top();
        s.pop();
    }
    return clock()-c;
}

int testDerivedStack() {
    DerivedArrayStack<int> s;
    long c = clock();
    for (int i = 0; i < 5000000; i++) {
        s.push(rand());
    }
    for (int i = 0; i < 5000000; i++) {
        s.top();
        s.pop();
    }
    return clock()-c;

}

int testArrayStack2() {
    ArrayStack<int> s(5000000);
    long c = clock();
    for (int i = 0; i < 5000000; i++) {
        s.push(rand());
    }
    for (int i = 0; i < 5000000; i++) {
        s.top();
        s.pop();
    }
    return clock()-c;
}

int testDerivedStack2() {
    DerivedArrayStack<int> s(5000000);
    long c = clock();
    for (int i = 0; i < 5000000; i++) {
        s.push(rand());
    }
    for (int i = 0; i < 5000000; i++) {
        s.top();
        s.pop();
    }
    return clock()-c;
}

int calculate() {
    cout<<"stack "<<testStack()<<endl;
    cout<<"Derived stack  "<<testDerivedStack()<<endl;
    cout<<"Derived stack 5000000 "<<testDerivedStack2()<<endl;
    cout<<"Array stack "<<testArrayStack()<<endl;
    cout<<"Array stack 5000000 "<<testArrayStack2()<<endl;
    return 0;
}
